import MfDataManage from 'comp/mf-data-manage.js';
export default {
    components: {
        MfDataManage
    },
    inject: ['http'],
    created() {
        this.getFlags();
    },
    data() {
        return {
            platformDialogVisible:false,
            flags:[]
        }
    },
    methods: {
        handleAdd() {
            this.platformDialogVisible = true
        },
        selectPlatform(flag) {
            this.$refs.manageRef.add({flag});
            this.platformDialogVisible = false
        },
        getFlags() {
            this.http.get('/ai/admin/key/platform').then(res => {
                this.flags = res.data
            })
        }
    },
    template: /*html*/`<div class="mf-page-key">
    <mf-data-manage ref="manageRef" table-name="ai:key">
        <template #toolbar-left>
            <el-button type="primary" @click="handleAdd" icon="Plus" title="新增"></el-button>
        </template>
    </mf-data-manage>
    <el-dialog v-model="platformDialogVisible" title="通道类型" width="650">
        <el-row algin="middle" justify="space-around" style="margin-top:30px;height:100px;">
            <el-col :span="6" v-for="flag in flags" style="text-align:center;">
                <el-button @click="selectPlatform(flag.value)" type="primary" plain round>{{flag.label}}</el-button>
            </el-col>
        </el-row>
    </el-dialog>
</div>
`,
}